<template>
  <div class="home-box">
    <el-container>
      <el-header style="height: 100px;" class="header">
        <!-- <div style="width:30px ;height: 30px;"><img src="../assets/banner1.png" alt=""></div> -->
        <div>
          后台管理系统
        </div>
        <div class="btn">
          <el-button type="danger" @click="outLogin" size="mini">
            退出登录
          </el-button>
        </div>
       
      </el-header>
      <el-container>
        <el-aside style="width: 150px;">
          <!-- <div @click="isCollapse = !isCollapse" style="height: 20px"></div> -->
          <el-menu
            default-active="2"
            class="el-menu-vertical-demo"
            background-color="#2c2c2c"
            text-color="#fff"
            active-text-color="#ffd04b"
            :unique-opened="true"
            :collapse-transition="false"
            :router="true"
            style="height: 100%;"
          >
            <el-submenu
              :index="item.id + ''"
              v-for="item in menuList"
              :key="item.id"
              
            >
              <template slot="title" >
                <i class="el-icon-phone-outline"></i>
                <span>{{ item.authName }}</span>
              </template>
              <el-menu-item
                :index="'/'+ itemSub.path"
                v-for="itemSub in item.children"
                :key="itemSub.id"
                style="min-width: 140px;padding-right: 0;"
              >
                <i class="el-icon-menu"></i>
                <span slot="title">{{ itemSub.authName }}</span>
              </el-menu-item>
            </el-submenu>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import { left_menu_req } from "../api/mune";
export default {
  data(){
    return{
      menuList:[],
      // isCollapse: false,
    };
  },
  async mounted(){
    this.getMenuList();
  },
  methods:{
    async getMenuList(){
      const result = await left_menu_req({
        methods:"get",
        url:"menus",
      });
      if(result.meta.status == 200){
        this.menuList = result.data;
        console.log(this.menuList);
      }
    },
    outLogin(){
      window.sessionStorage.removeItem("token");
      this.$router.push("/login");
    }
  }
}
</script>

<style lang="scss" scoped>
.home-box{
  height: 100%;
}
.el-container{
  height: 100%;
  
}
.el-header {
    background-color: #B3C0D1;
    color: #333;
    text-align: center;
    line-height: 100px;
    display: flex;
    justify-content: space-between;
  }
  .el-aside {
    background-color: #D3DCE6;
    color: #333;
    text-align: center;
    line-height: 200px;
    .el-submenu__title{
      padding-left: 0;
    }
    .el-menu-item{
      width: 100%;
      padding-left: 0;
    }
  }
  .el-main {
    background-color: #E9EEF3;
    color: #333;
    text-align: center;
    // line-height: 160px;
  }

</style>